<!-- const TypeEnumValue = {
    1: 'input',
    2: 'checkbox',
    3: 'radio',
    4: 'textarea',
    5: 'select',
    6: 'img',
    7: 'date'
 };
  -->

<form action="<%= action%>" method="post">
    <% if (id) {  %>
        <label class="mb-2">id</label>
        <input class="form-control" value="<%= id%>" name="id">
    <%}%>
    <% let widgets = form && form.widgets || []%>
    <% let likeFormFieldsValue = formFieldsValue || {}%>
    <% for(let i = 0; i < widgets.length; i++) {%>
        <% let item = (widgets[i] || {}) %>
        <% let options = (item && item.dictsetInfo && item.dictsetInfo.options) || [] %>
        <div class="form-group">
            <label class="mb-2"><%= item.label %></label>
            <% if(item.type == 1) {%>
                <input name="<%= item.value %>" class="form-control" value="<%= likeFormFieldsValue[item.value] %>"/>
            <% } %>

            <% if(item.type == 2) {%>
                <div>
                    <% options.forEach(function(option, index) { %>
                        <input type="checkbox" name="<%= option && option.value %>" class="form-check-input" value="<%= likeFormFieldsValue[item.value] %>"/>
                        <span class="form-check-label"><%= option && option.key %></span>
                    <% }) %>
                </div>
            <% } %>

            <% if(item.type == 3) {%>
                <div>
                    <% options.forEach(function(option, index) { %>
                            <% if (likeFormFieldsValue[item.value] === option.value) { %>
                                <input type="radio" value="<%= option && option.value %>" name="<%= item && item.value %>" class="custom-control-input" value="<%= likeFormFieldsValue[item.value] %>" checked>
                            <% } else {%>
                                <input type="radio" value="<%= option && option.value %>" name="<%= item && item.value %>" class="custom-control-input" value="<%= likeFormFieldsValue[item.value] %>" >
                            <% } %>
                            <label class="custom-control-label" for="customRadioInline1"><%= option && option.key %></label>
                    <% }) %>
                </div>
            <% } %>

            <% if(item.type == 4) {%>
                <textarea name="<%= item.value %>" class="form-control" value="<%= likeFormFieldsValue[item.value] %>" />
            <% } %>

            <% if(item.type == 5) {%>
                <textarea name="<%= item.value %>" class="form-control" value="<%= likeFormFieldsValue[item.value] %>"/>
            <% } %>
        </div>
    <% } %>

    <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button class="btn btn-primary" type="submit">保存</button>
      </div>
</form>